package controller;

import java.io.IOException;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class Test extends HttpServlet {
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		String url = request.getRequestURL().toString();
		String[] split = url.split("/");
		if (split.length == 6) {
			int day =  Integer.parseInt(split[5]);
			int month = Integer.parseInt(split[4]);
			int year = Integer.parseInt(split[3]);
			Calendar cal = Calendar.getInstance();
			cal.set(year, month, day);
			System.out.println("Inputttttttttttt" + cal.getTime());
			request.setAttribute("date", cal);
			request.getRequestDispatcher("/datety.jsp").forward(request, response);
		} else {
			response.sendRedirect("/home");
		}		
	}

}
